<layout name="page" />
<block name="content">
	<style>
		.user_list {
			height: 400px;
			overflow-y: auto;
		}
		.user_list li.tbody {
			cursor: pointer;
		}
		.avtar {
			box-sizing:border-box;
			border: 0px solid #ccc;
			border-radius: 50%;
			width: 50px;
			height: 50px;
		}
		.ul-table span {
			line-height: 24px;
		}
	</style>
	{:widget('page_header/search',array('name'=>'职员查询'))}
	<div class="sub-frame">
		<div class="sub-sidebar gray">
			<?php echo $menu ?>
		</div>
		<div class="sub-content" id="contact" >
			<div class="ul-table">
				<ul>
					<foreach name="search" val="vo">
						<li>
							<span class="col-8 text-center"><img class="pic avtar" src="{$vo.pic}"></span>
							<span class="col-19 x1">
								<div class="frame">
									<div class="box col-12">
										<div class="">
											<span class="name">{$vo.name}</span><span class="position">{$vo.position_name}</span>
										</div>
										<div class="">
											<span class=" dept">{$vo.dept_name}</span>
										</div>
									</div>
									<div class="box col-12">
										<div>
											<span class="mobile_tel" href="tel:{$vo.mobile_tel}">{$vo.mobile_tel}</span>
										</div>
										<div>
											<span class="email ">{$vo.email}</span>
										</div>
									</div>
								</div></span>
						</li>
					</foreach>
				</ul>
			</div>
		</div>
	</div>
	<div id="sample" class="hidden"  >
		<li>
			<span class="col-8 text-center"><img class="pic avtar" src=""></span>
			<span class="col-19 x1">
				<div class="frame">
					<div class="box col-12">
						<div class="">
							<span class="name"></span><span class="position"></span>
						</div>
						<div class="">
							<span class=" dept">总经理办公室</span>
						</div>
					</div>
					<div class="box col-12">
						<div>
							<span class="mobile_tel"></span>
						</div>
						<div>
							<span class="email "></span>
						</div>
					</div>
				</div></span>
		</li>
	</div>
</block>
<block name="js">
	<php>
		if($is_weixin){
	</php>
	<script src="http://res.wqq.com/open/js/jweixin-1.1.0.js"></script>
	<script type="text/javascript">
		wconfig({
			debug : false,
			appId : '{$signPackage.appId}',
			timestamp : '{$signPackage.timestamp}',
			nonceStr : '{$signPackage.nonceStr}',
			signature : '{$signPackage.signature}',
			jsApiList : ['openEnterpriseChat']
		});

		function open_wechat($emp_no) {
			wopenEnterpriseChat({
				userIds : $emp_no, // 必填，参与会话的成员列表。格式为userid1;userid2;...，用分号隔开，最大限制为1000个。userid单个时为单聊，多个时为群聊。
				groupName : "", // 必填，会话名称。单聊时该参数传入空字符串""即可。
				success : function(res) {
					// 回调
				},
				fail : function(res) {
					if (res.errMsg.indexOf('function not exist') > 0) {
						alert('版本过低请升级');
					}
				}
			});
		}
	</script>
	<php>
		}
	</php>
	<script>
		layui.use(['global'], function() {
			var $ = layui.jquery;
			$(".sub-sidebar .tree_menu a").click(function() {
				$(".sub-sidebar .tree_menu a").each(function() {
					$(this).attr("class", "");
				});
				$(this).attr("class", "active");
				send_ajax("{:url('read')}", "id=" + $(this).attr("node"), function(ret) {
					show_data(ret);
					
					height=$("#contact").offset().top;
					console.log(height);
					$('html,body').animate({scrollTop:height+'px'},600);
					//document.getElementById("contact").scrollIntoView(false);
				});				
				return false;
			});

			function show_data(ret){
				$(".ul-table ul li").remove();
				for (var s in ret.data) {
					$("#sample .emp_no").text(ret.data[s].emp_no);
					$("#sample .name").text(ret.data[s].name);
					$("#sample .position").text(ret.data[s].position_name);
					$("#sample .dept").text(ret.data[s].dept_name);
					$("#sample .email").text(ret.data[s].email);
					$("#sample .pic").attr('src', ret.data[s].pic);
					$mobile = $("<a></a>");
					$mobile.attr("href", "tel:" + ret.data[s].mobile_tel);
					$mobile.html(ret.data[s].mobile_tel);

					$("#sample .mobile_tel").html($mobile);
					html = $("#sample").html();
					$(".ul-table ul").append(html);
					$("#sample li span a").text("");
				}
			}
		});
	</script>
</block>